finding the nth term